<?php
/**
 * Builds up a programmatic model for SQL column definition clause to be used by CREATE and ALTER queries.
 */
abstract class SQLColumnDefinitionClause extends AbstractSQLClause {
	/**
	 * Defines column name.
	 * 
	 * @param string $strColumnName
	 * @return SQLColumnDefinitionClause
	 */
	public function setName($strColumnName) {
		$this->tblContents["NAME"]=$strColumnName;
		return $this;
	}
	
	/**
	 * Defines column type & length.
	 * 
	 * @param string $strColumnDataType
	 * @param string|int $mixDataLength
	 * @return SQLColumnDefinitionClause
	 */
	public function setDataType($strColumnDataType, $mixDataLength=null) {
		$this->tblContents["DATA_TYPE"]=$strColumnDataType;
		if($mixDataLength) $this->tblContents["LENGTH"]=$mixDataLength;
		return $this;
	}
	
	/**
	 * Defines column default value.
	 * 
	 * @param mixed $mixValue
	 * @return SQLColumnDefinitionClause
	 */
	public function setDefaultValue($mixValue) {
		$this->tblContents["DEFAULT_VALUE"]=$mixValue;
		return $this;
	}
	
	/**
	 * Sets column as nullable.
	 * 
	 * @return SQLColumnDefinitionClause
	 */
	public function setNullable() {
		$this->tblContents["IS_NULLABLE"]=true;
		return $this;
	}
	
	/**
	 * Sets column as primary key.
	 * 
	 * @return SQLColumnDefinitionClause
	 */
	public function setPrimary() {
		$this->tblContents["IS_PRIMARY"]=true;
		return $this;
	}
	
	/**
	 * Sets column as autoincremented.
	 * 
	 * @return SQLColumnDefinitionClause
	 */
	public function setAutoincrement() {
		$this->tblContents["IS_AUTOINCREMENT"]=true;
		return $this;
	}
}